Communication Device

ABSTRACT

A communication device may monitor an establishment of a first type of communication link between a communication device and an external device while the communication device is in a first state in which a P2P mode of an NFC standard is active and a first mode of the NFC standard is active. The communication device may send first data to the external device by using the first type of communication link. The first data may include a command for causing the external device to execute an activation of a particular application. The communication device may change the state of the communication device from the first state to a second state in which the P2P mode is active, and perform the two-way communication with the external device that operates the particular application by using a second type of communication link.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.15/287,054 filed Oct. 6, 2016, which is a continuation of U.S. patentapplication Ser. No. 13/959,786 filed Aug. 6, 2013, issued as U.S. Pat.No. 9,485,608 on Nov. 1, 2016, which claims priority to Japanese PatentApplication No. 2012-173602, filed on Aug. 6, 2012, the contents ofwhich are hereby incorporated by reference into the presentapplications.

TECHNICAL FIELD

The technology disclosed in the present specification relates to acommunication device that performs a two-way communication with anexternal device according to an NFC (an abbreviation of Near FieldCommunication) scheme.

DESCRIPTION OF RELATED ART

A system comprising a communication terminal and an NFC device is known.In a state where an application is active, the communication terminalshifts to a R/W mode when a data read operation is performed by a user.In a state where the communication terminal is in the R/W mode and theNFC device is in a passive tag mode, a data read request is sent fromthe communication terminal to the NFC device. Next, each of thecommunication terminal and the NFC device shifts to a P2P mode. In astate where the communication terminal is in the P2P mode and the NFCdevice is in the P2P mode, data is transferred from the NFC device tothe communication terminal. When data transfer completes, thecommunication terminal shifts to the passive tag mode, and the NFCdevice shifts to the R/W mode.

SUMMARY

In the technique described above, when a data communication is to beperformed between the communication terminal and the NFC device, it isassumed that an application of the communication terminal is active, anda situation is not considered in which the application of thecommunication terminal is not active.

In the present specification, a situation is considered in which anapplication of the external device is not active, and a technique isdisclosed for appropriately performing a two-way communication of targetdata between a communication device and an external device.

One aspect of the technique disclosed in the present specification maybe a communication device configured to perform a two-way communicationwith an external device according to an NFC (Near Field Communication)scheme complying with an NFC standard. The communication device maycomprise: an NFC interface configured to operate in the NFC scheme; aprocessor; and a memory configured to store computer executableinstructions. The computer executable instructions, when executed by theprocessor, may cause the communication device to execute: monitoring anestablishment of a first type of communication link between thecommunication device and the external device while the communicationdevice is in a first state in which a P2P (Peer to Peer) mode of the NFCstandard is not active and a first mode of the NFC standard is active,the first type of communication link being for performing a datacommunication between the communication device in the first mode and theexternal device in a second mode of the NFC standard; sending first datato the external device via the NFC interface by using the first type ofcommunication link, in a case where the first type of communication linkis established while the communication device is in the first state, thefirst data including a command for causing the external device toexecute an activation of a particular application, the particularapplication being for performing the two-way communication; changing, ata predetermined timing after sending the first data, a state of thecommunication device from the first state to a second state in which theP2P mode is active; performing the two-way communication with theexternal device, that operates the particular application, via the NFCinterface by using a second type of communication link, in a case wherethe second type of communication link is established between thecommunication device and the external device while the communicationdevice is in the second state, the second type of communication linkbeing for performing a data communication between the communicationdevice in the P2P mode and the external device in the P2P mode.

Note that a controlling method, computer executable instructions, and anon-transitory computer readable medium for storing the computerexecutable instructions which are for realizing the communication devicedescribed above are newly useful. A communication system including thecommunication device and the external device is also newly useful.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows the configuration of a communication system.

FIG. 2 shows a flowchart of a communication process on an MFP of a firstembodiment.

FIG. 3 shows a sequence chart of a communication of a case A of thefirst embodiment.

FIG. 4 shows a flowchart of a communication process on an MFP of asecond embodiment.

FIG. 5 shows a sequence chart of a communication of a case B1 of thesecond embodiment.

FIG. 6 shows a sequence chart of a communication of a case B2 of thesecond embodiment.

FIG. 7 shows a sequence chart of a communication of a case B3 of thesecond embodiment.

FIG. 8 shows a sequence chart of a communication of a case B4 of thesecond embodiment.

EMBODIMENT First Embodiment

(Configuration of Communication System 2)

As shown in FIG. 1, a communication system 2 comprises an AP (anabbreviation of Access Point) 4, a PC (an abbreviation of PersonalComputer) 6, a multi-function peripheral (called “MFP (an abbreviationof Multi-Function Peripheral)” below) 10, portable terminals 50, 52, andan authentication card 54. The MFP 10, the portable terminals 50, 52,and the authentication card 54 are each capable of performing acommunication of a communication scheme of the NFC standard (i.e., anNFC scheme). In the present embodiment, the NFC standard isinternational standard ISO/IEC21481 or ISO/IEC18092. The communicationof the NFC scheme is a wireless communication using 13.56 MHz band radiowaves. Further, the MFP 10 and the portable terminals 50, 52 are eachcapable of performing a wireless communication using a communicationnetwork different from a communication link of the NFC scheme.

(Configuration of MFP 10)

The MFP 10 has an operating unit 12, a display unit 14, a networkinterface (described as “I/F,” hereinafter) 16, a print executing unit18, a scan executing unit 20, an NFC I/F 22, and a controller 30.

The operating unit 12 comprises a plurality of keys. A user can inputvarious commands to the MFP 10 by operating the operating unit 12. Thedisplay unit 14 is a display for displaying various information. Thenetwork I/F 16 is an I/F for connecting with a wireless network.Moreover, this wireless network is a network for performing a wirelesscommunication different from the communication of the NFC scheme, beinge.g., a network complying with IEEE (an abbreviation of The Institute ofElectrical and Electronics Engineers, Inc.) standard 802.11 andstandards conforming thereto (e.g., 802.11a, 11b, 11g, 11n, etc.). Inthe present embodiment, the wireless network is a network including theAP 4, the PC 6 and the MFP 10. The print executing unit 18 is an ink jetmethod, laser method, etc. printing mechanism. The scan executing unit20 is a CCD, CIS, etc. scanning mechanism.

The NFC I/F 22 is an interface for executing the NFC schemecommunication. The NFC I/F 22 is configured by a chip different from thenetwork I/F 16. The network I/F 16 and the NFC I/F 22 differ from eachother in terms of the following points.

In other words, the speed of wireless communication using the networkI/F 16 is higher than the speed of wireless communication using the NFCI/F 22. The frequency of a carrier wave in the wireless communicationperformed using the network I/F 16 is different from the frequency of acarrier wave in the wireless communication performed using the NFC I/F22. When the distance between the MFP 10 and the portable device 50 isapproximately 10 cm or less, the MFP 10 can execute the NFC schemecommunication with the portable device 50 using the NFC I/F 22. On theother hand, even when the distance between the MFP 10 and the portabledevice 50 is equal to or greater than 10 cm, or equal to or less than 10cm, the MFP 10 can execute the wireless communication with the portabledevice 50 using the network I/F 16. In other words, the maximum distancein which the MFP 10 can execute the wireless communication with acommunication-destination device (e.g., the portable device 50) via thenetwork I/F 16 is greater than the maximum distance in which the MFP 10can execute the wireless communication with thecommunication-destination device via the NFC I/F 22. It should be notedthat the wireless communication using the network I/F 16 is referred toas “network wireless communication” hereinafter.

The controller 30 has a CPU 32 and a memory 34. The CPU 32 executesvarious processes in accordance with program 36 stored in the memory 34.The memory 34 is configured by a ROM, a RAM, a hard disk, and the like.The memory 34 stores therein the program 36 that is executed by the CPU32.

The program 36 includes an application program and a protocol stack. Theapplication program is a program executed by the CPU 32 to process anapplication layer of the OSI reference model. The protocol stack is aprogram executed by the CPU 32 to process a layer lower than theapplication layer of the OSI reference model. The protocol stackincludes a P2P (an abbreviation of Peer to Peer) program, a R/W program,and a CE program. The P2P program is a program for executing a processaccording to a P2P-mode of the NFC standard. The R/W program is aprogram for executing a process according to a Reader/Writer-mode of theNFC standard. The CE program is a program for executing a processaccording to a CE (an abbreviation of Card Emulation) mode of the NFCstandard. These programs are used for executing processes complying withthe NFC standards defined by the NFC forum.

Below, a device capable of performing a communication of the NFC scheme(the MFP 10, the portable terminals 50, 52, the authentication card 54,etc.) is called an “NFC device”. Further, below, Reader mode and Writermode combined may be described briefly as “R/W mode”.

NFC devices include devices capable of using all three modes P2P mode,R/W mode, and CE mode, and devices capable of using only one or twomodes of the three modes. In the present embodiment, the MFP 10 and theportable terminal 52 are devices capable of using all three modes.However, the portable terminal 50 is capable of using the P2P mode andR/W mode, but is not capable of using the CE mode. Further, theauthentication card 54 is a card of the NFC standard. More specifically,the authentication card 54 is capable of using the CE mode, but is notcapable of using the P2P mode and the R/W mode.

The P2P mode is a mode for performing a two-way communication between apair of NFC devices. For example, a situation is assumed in which theP2P mode is active in both a first NFC device and a second NFC device.In this case, a communication link corresponding to the P2P mode (called“communication link of P2P” below) is established between the first NFCdevice and the second NFC device. In this case, e.g., the first NFCdevice sends first data to the second NFC device by using thecommunication link of P2P. Then, the second NFC device sends second datato the first NFC device by using the same communication link of P2P.Thereby, a two-way communication is realized. An NFC device which isISO/IEC 1443 Type A, and an NFC device which is ISO/IEC 18092 Type F,these being determined by the NFC Forum, are capable of using the P2Pmode, whereas an NFC device which is ISO/IEC 1443 Type B is not capableof using the P2P mode.

The R/W mode and the CE mode are modes for performing a one-waycommunication between a pair of NFC devices. The CE mode is a mode foran NFC device to operate as a “card”, this being a format determined bythe NFC Forum. Any Type A NFC device, Type F NFC device, and Type B NFCdevice is capable of using the CE mode. The Reader mode is a mode forreading data from an NFC device operating as a card in the CE mode. TheWriter mode is a mode for writing data to an NFC device operating as acard in the CE mode. Moreover, in the Reader mode, data can also be readfrom a card of the NFC standard (i.e., the authentication card 54).Further, in the Writer mode, data can also be written to a card of theNFC standard.

For example, a situation is assumed in which the Reader mode is activein the first NFC device, and the CE mode is active in the second NFCdevice. In this case, a communication link corresponding to the Readermode and the CE mode is established between the first NFC device and thesecond NFC device. In this case, using the communication link, the firstNFC device executes an operation for reading data from a pseudo cardwithin the second NFC device, thereby receiving the data from the secondNFC device.

Further, e.g., a situation is assumed in which the Writer mode is activein the first NFC device, and the CE mode is active in the second NFCdevice. In this case, a communication link corresponding to the Writermode and the CE mode is established between the first NFC device and thesecond NFC device. In this case, using the communication link, the firstNFC device executes an operation for writing data to the pseudo cardwithin the second NFC device, thereby sending the data to the second NFCdevice.

As described above, various combinations of modes can be considered fora pair of NFC devices to execute a communication of the NFC scheme. Forexample, the following five patterns can be considered as combinationsof modes of the pair of NFC devices: “P2P mode, P2P mode”, “Reader mode,CE mode”, “Writer mode, CE mode”, “CE mode, Reader mode”, “CE mode,Writer mode”.

Moreover, the NFC device cannot form a state in which both the Readermode and the Writer mode are active. That is, in the NFC device, if theReader mode is active, the Writer mode is stopped. Further, in the NFCdevice, if the Writer mode is active, the Reader mode is stopped.

Further, the NFC device can establish a communication link correspondingto a mode that is active, but cannot establish a communication linkcorresponding to a mode that is not active. For example, in the MFP 10,in a case where the CE mode is active, and the P2P mode and the R/W modeare not active, the MFP 10 can establish a communication link for theMFP 10 to operate in the CE mode, but cannot establish anothercommunication link (i.e., a communication link for the MFP 10 to operatein the P2P mode, the Reader mode, or the Writer mode).

When power of the MFP 10 is turned ON, the MFP 10 shifts to an initialstate in which only the CE mode is active, and the P2P mode and the R/Wmode are not active. Upon receiving a P2P activation command (to bedescribed) (YES in S32 of FIG. 2), the MFP 10 shifts from the initialstate to a state in which only the P2P mode is active, and the R/W modeand the CE mode are not active (S36). Moreover, while the power of theMFP 10 is ON, the MFP 10 maintains a state in which the R/W mode is notactive. Consequently, in a variant, the MFP 10 need not be capable ofusing the R/W mode.

(Configuration of Portable Terminals 50, 52)

The portable terminals 50, 52 are transportable terminals such as, e.g.,a mobile phone (e.g., smart phone), PDA, notebook PC, tablet PC,portable music playback device, portable film playback device, etc. Theportable terminals 50, 52 each comprise a network I/F and an NFC I/F forconnecting with a wireless network. Consequently, the portable terminals50, 52 are each capable of performing a wireless communication with theMFP 10 via the network I/F, and a wireless communication with the MFP 10by using the NFC I/F.

An application program (called “application for MFP” below) for causingthe MFP 10 to execute various functions (e.g., print function, scanfunction, etc.) can be installed on each of the portable terminals 50,52. Moreover, in the present embodiment, the application for MFP isinstalled on the portable terminals 50, 52 from an internet server (notshown) provided by a vendor of the MFP 10.

As described above, in the present embodiment, the portable terminal 50is capable of using the P2P mode and the R/W mode, but is not capable ofusing the CE mode. The portable terminal 50 comprises a first OS (anabbreviation of Operation System) program. The first OS program is,e.g., version 4.0 of Android (registered trademark). The first OSprogram causes the portable terminal 50 to operate as follows. That is,when power of the portable terminal 50 is turned ON, the portableterminal 50 shifts to an initial state in which the P2P mode and theReader mode are active, and the Writer mode is not active. In a casewhere the application for MFP has not been installed, the portableterminal 50 maintains the initial state. In a case where the applicationfor MFP is not active although the application for MFP has beeninstalled, the portable terminal 50 maintains the initial state. Uponactivation of the application for MFP, the portable terminal 50 shiftsfrom the initial state to a state in which the P2P mode and the Writermode are active, and the Reader mode is not active.

Further, as described above, the portable terminal 52 is capable ofusing the P2P mode, the R/W mode, and the CE mode. The portable terminal52 comprises a second OS program different from the first OS program.The second OS program operates the portable terminal 52 as follows. Thatis, when power of the portable terminal 52 is turned ON, the portableterminal 52 shifts to an initial state in which the P2P mode, the Readermode, and the CE mode are active, and the Writer mode is not active. Ina case where the application for MFP has not been installed, theportable terminal 52 maintains the initial state. In a case where theapplication for MFP is not active although the application for MFP hasbeen installed, the portable terminal 52 maintains the initial state.Upon activation of the application for MFP, the portable terminal 52shifts from the initial state to a state in which the P2P mode, theWriter mode, and the CE mode are active, and the Reader mode is notactive.

Moreover, the AP 4, the PC 6, and the authentication card 54 are used ina second embodiment, to be described. Consequently, a description ofthese devices is omitted here.

(Poll Operation and Listen Operation)

Next, a Poll operation and a Listen operation executed by the NFC devicewill be described. For example, in the MFP 10, the CPU 32 does notexecute the Poll operation and the Listen operation according to theprogram 36, but the NFC I/F 22 executes the Poll operation and theListen operation. The Poll operation is an operation in which a pollingsignal is sent, and a response signal in response to the polling signalis received. Further, the Listen operation is an operation in which apolling signal is received, and a response signal in response to thepolling signal is sent.

The NFC I/F 22 of the MFP 10 is capable of operating in any mode of Pollmode for executing the Poll operation, Listen mode for executing theListen operation, and a mode in which neither the Poll operation nor theListen operation are executed (called “non-execution mode” below). TheNFC I/F 22 operates sequentially in the Poll mode, the Listen mode, andthe non-execution mode. For example, the NFC I/F 22 executes one set ofoperations in which the NFC I/F 22 operates in the Poll mode, thenoperates in the Listen mode, and then operates in the non-executionmode. The NFC I/F 22 repeatedly executes the one set of operations.

In the Poll mode, the NFC I/F 22 sends a polling signal, and monitorswhether a response signal is received. Specifically, the NFC I/F 22repeats the following operation: (1) sending a polling signal to which aType A NFC device can respond (i.e., a polling signal corresponding toType A), and monitoring reception of a response signal for apredetermined time, (2) if not receiving a response signal, sending apolling signal to which a Type B NFC device can respond (i.e., a pollingsignal corresponding to Type B), and monitoring reception of a responsesignal for a predetermined time and, (3) if not receiving a responsesignal, sending a polling signal to which a Type F NFC device canrespond (i.e., a polling signal corresponding to Type F), and monitoringreception of a response signal for a predetermined time. In a case wherethe NFC I/F 22 receives a response signal from an NFC device within thepredetermined time, the NFC device can be said to be of a Type of NFCdevice corresponding to the polling signal received immediately prior tosending the response signal. In case of the NFC I/F 22 receiving theresponse signal, further, the NFC device that is the source of theresponse signal sends, to the NFC device, a query signal for enquiringwhich mode is active. Consequently, the NFC I/F 22 receives anactivation mode signal from the NFC device. The activation mode signalindicates that both the P2P mode and the CE mode are active in the NFCdevice, that only the P2P mode is active, or that only the CE mode isactive.

In the Listen mode, the NFC I/F 22 monitors whether a polling signal isreceived and, upon receiving the polling signal, sends a responsesignal. The NFC I/F 22 sends a response signal to the NFC device that isthe source of the polling signal only in case of receiving a pollingsignal of the Type corresponding to the NFC I/F 22. In case of sendingthe response signal to the NFC device, the NFC I/F 22 further receives aquery signal from the NFC device, and sends an activation mode signal tothe NFC device.

In the non-execution mode, the NFC I/F 22 does not send a polling signaland, further, does not send a response signal even if receiving apolling signal.

Each of the portable terminals 50, 52 also repeatedly executes theaforementioned one set of operations. Consequently, e.g., in a casewhere distance between the MFP 10 and the portable terminal 50 is lessthan 10 cm and a period in which the NFC I/F 22 of the MFP 10 isoperating in the Poll mode matches a period in which the portableterminal 50 is operating in the Listen mode, the NFC I/F 22 executes thePoll operation of sending a polling signal to the portable terminal 50and receiving a response signal from the portable terminal 50. Further,e.g., in a case where distance between the MFP 10 and the portableterminal 50 is less than 10 cm and a period in which the NFC I/F 22 isoperating in the Listen mode matches a period in which the portableterminal 50 is operating in the Poll mode, the NFC I/F 22 executes theListen operation of receiving a polling signal from the portableterminal 50 and sending a response signal to the portable terminal 50.Moreover, below, the NFC device which executed the Poll operation, andthe NFC device which executed the Listen operation are called “Polldevice” and “Listen device” respectively.

In a case where the NFC I/F 22 executes the Poll operation, i.e., in acase where the MFP 10 is the Poll device, processes for subsequentcommunication are taken over by the CPU 32. Specifically, first,information is delivered from the NFC I/F 22 to the CPU 32, thisinformation indicating the mode in which the NFC device that is theListen device (e.g., the portable terminal 50) is capable of executingoperation (i.e., information indicating the received activation modesignal). The CPU 32 decides the mode in which the MFP 10 is to operatebased on a current state of the MFP 10 (i.e., the mode which iscurrently active in the MFP 10) and the information delivered from theNFC I/F 22. Specifically, the CPU 32 decides, in the following manner,the mode in which the MFP 10, this being the Poll device, is to operate.

In the NFC standard, the Poll device is capable of operating in the P2Pmode or the R/W mode, but is not capable of operating in the CE mode.Consequently, in case the MFP 10 is the Poll device, the CPU 32 decidesthat the MFP 10 is to operate in the P2P mode or the R/W mode. Forexample, in case the current state of the MFP 10, which is the Polldevice, is a state where the P2P mode is active and the R/W mode is notactive, and the information delivered from the NFC I/F 22 indicates thatthe P2P mode is active in the NFC device, which is the Listen device,the CPU 32 decides that the MFP 10 is to operate in the P2P mode. Inthis case, the CPU 32 sends an Activation command corresponding to theP2P mode to the NFC device, and receives an OK command from the NFCdevice. Thereby, a P2P mode communication link is established betweenthe MFP 10, which is the Poll device, and the NFC device, which is theListen device. Moreover, in the present embodiment, the R/W mode cannotbe activated in the MFP 10, and consequently the CPU 32 does not decidethat the MFP 10 is to operate in the R/W mode.

Further, in a case, also, where the NFC I/F 22 executes the Listenoperation, i.e., in case the MFP 10 is the Listen device, processes forsubsequent communication are taken over by the CPU 32. The CPU 32decides the mode in which the MFP 10 is to operate based on anActivation signal received from the NFC device, which is the Polldevice. Specifically, the CPU 32 decides, in the following manner, themode in which the MFP 10, this being the Listen device, is to operate.

In the NFC standard, the Listen device is capable of operating in theP2P mode or the CE mode, but is not capable of operating in the R/Wmode. Consequently, in the case where the MFP 10 is the Listen device,the CPU 32 decides that the MFP 10 is to operate in the P2P mode or theCE mode. For example, in case the current state of the MFP 10, which isthe Listen device, is a state where the P2P mode is active and the CEmode is not active, and a current state of the NFC device, which is thePoll device, is a state where the P2P mode is active, the CPU 32receives an Activation command corresponding to the P2P mode from theNFC device. In this case, the CPU 32 decides that the MFP 10 is tooperate in the P2P mode, and sends an OK command to the NFC device.Thereby, a communication link of P2P is established between the MFP 10,which is the Listen device, and the NFC device, which is the Polldevice.

Further, e.g., in case the current state of the MFP 10, which is theListen device, is a state in which the CE mode is active and the P2Pmode is not active, and the current state of the NFC device, which isthe Poll device, is a state in which the Reader mode or the Writer modeis active, the CPU 32 receives an Activation command corresponding tothe R/W mode from the NFC device. In this case, the CPU 32 decides thatthe MFP 10 is to operate in the CE mode, and sends an OK command to theNFC device. Thereby, a communication link corresponding to the CE modeand the R/W mode is established between the MFP 10, which is the Listendevice, and the NFC device, which is the Poll device.

Moreover, in case the communication link corresponding to the CE modeand the R/W mode is established, the CPU 32 further receives informationfrom the NFC device indicating whether the NFC device is operating inthe Reader mode or the Writer mode. Consequently, e.g., in case ofreceiving information indicating that the NFC device is operating in theReader mode, a communication link corresponding to the CE mode and theReader mode can be said to be established between the MFP 10, which isthe Listen device, and the NFC device, which is the Poll device (called“communication link of MFP (CE)-NFC device (R)” below). Further, e.g.,in case of receiving information indicating that the NFC device isoperating in the Writer mode, a communication link corresponding to theCE mode and the Writer mode can be said to be established between theMFP 10, which is the Listen device, and the NFC device, which is thePoll device, (called “communication link of MFP (CE)-NFC device (W)”below).

(Communication Process on MFP; FIG. 2)

Next, the contents of processes executed by the CPU 32 of the MFP 10according to the program 36 will be described with reference to FIG. 2.When the power of the MFP 10 is turned ON, in S10 the CPU 32 shifts thestate of the MFP 10 to the initial state in which the CE mode is activeand the P2P mode and the R/W mode are not active.

As shown in S20, while the state of the MFP 10 is the initial state, theCPU 32 monitors whether a communication link of MFP (CE)-NFC device (R)is established. As described above, in case of receiving informationindicating that the NFC device is operating in the Reader mode, the CPU32 determines that the communication link of MFP (CE)-NFC device (R) hasbeen established. In this case, the CPU 32 determines YES in S20, andproceeds to S22.

In S22, using the communication link of MFP (CE)-NFC device (R), the CPU32 sends URL (an abbreviation of Uniform Resource Locator) data to theNFC device via the NFC I/F 22. As described above, an internet serverprovided by the vendor of the MFP 10 stores the application for MFP and,in response to a request from an external device, permits the externaldevice to download and install the application for MFP. The URL datasent in S22 represents a URL of the application for MFP (i.e., a fileaddress of the application for MFP within the internet server). The URLdata includes a Smart Poster command that is defined by the NFCstandard. The Smart Poster command is a command for causing the NFCdevice (i.e., the portable terminals 50, 52) to execute activation ofthe application for MFP. Moreover, an operation executed by the NFCdevice when the URL data is received will be described in detail later.When S22 ends, the CPU 32 proceeds to S24.

In S24, the CPU 32 disconnects the communication link of MFP (CE)-NFCdevice (R). Specifically, the CPU 32 performs a communication of aDeactivation command and an OK command. It is determined in the NFCstandard that the Poll device sends the Deactivation command, i.e., theListen device receives the Deactivation command. When S24 is executed,the NFC device is the Poll device, and the MFP 10 is the Listen device.Consequently, the CPU 32 receives the Deactivation command from the NFCdevice via the NFC I/F 22, and sends the OK command to the NFC devicevia the NFC I/F 22. Consequently, the communication link of MFP (CE)-NFCdevice (R) is disconnected.

Moreover, it can occur that, due to the NFC device moving away from theMFP 10, the distance between the MFP 10 and the portable terminal 50becomes a distance in which NFC communication cannot be performed beforethe NFC device sends the Deactivation command to the MFP 10. In thiscase, in S24 the link is forcibly disconnected without performing acommunication of the Deactivation command and the OK command. When S24ends, the CPU 32 returns to S20.

As shown in S30, while the state of the MFP 10 is the initial state, theCPU 32 further monitors whether a communication link of MFP (CE)-NFCdevice (W) is established. As described above, in the case of receivinginformation indicating that the NFC device is operating in the Writermode, the CPU 32 determines that the communication link of MFP (CE)-NFCdevice (W) has been established. In this case, the CPU 32 determines YESin S30, and proceeds to S32.

In S32, using the communication link of MFP (CE)-NFC device (W), the CPU32 monitors whether a P2P activation command is received from the NFCdevice via the NFC I/F 22. The P2P activation command is a command forcausing the MFP 10 to execute an activation of the P2P mode. The P2Pactivation command is a command prepared according to the applicationfor MFP. That is, receiving the P2P activation command from the NFCdevice means that the application for MFP is active in the NFC device.In case of receiving the P2P activation command from the NFC device, theCPU 32 determines YES in S32, and proceeds to S34. On the other hand, incase of not receiving the P2P activation command from the NFC device(i.e., in case of receiving a command different from the P2P activationcommand, or in case of not receiving any command), the CPU 32 determinesNO in S32, and proceeds to S24.

In S34, the CPU 32 performs a communication of the Deactivation commandand the OK command, as in S24, and disconnects the communication link.Next, in S36, in accordance with the P2P activation command, the CPU 32stops the CE mode and activates the P2P mode. Consequently, the CPU 32can change the state of the MFP 10 from the initial state to a state inwhich the P2P mode is active and the R/W mode and the CE mode are notactive. Moreover, as described above, receiving the P2P activationcommand from the NFC device means that the application for MFP is activein the NFC device. Consequently, the MFP 10 can change the state of theMFP 10 from the initial state to the state in which the P2P mode isactive at an appropriate timing (i.e., a timing at which the applicationfor MFP is active in the NFC device). Further, in S36, the CPU 32 doesnot maintain the state in which the CE mode is active, and stops the CEmode. Consequently, in S38, to be described, establishment of acommunication link for the MFP 10 to operate in the CE mode can besuppressed, and a communication link in P2P is establishedappropriately. When S36 ends, the CPU 32 proceeds to S38.

In S38, the CPU 32 monitors whether a communication link of P2P isestablished. As described above, e.g., in case the MFP 10 is the Polldevice, the CPU 32 sends an Activation command corresponding to the P2Pmode to the NFC device and, in case of receiving an OK command from theNFC device, determines that a communication link of P2P has beenestablished. In this case, the CPU 32 determines YES in S38, andproceeds to S40. Further, e.g., in case the MFP 10 is the Listen device,the CPU 32 receives an Activation command corresponding to the P2P modefrom the NFC device and, in case of sending an OK command to the NFCdevice, determines that a communication link of P2P has beenestablished. In this case, also, the CPU 32 determines YES in S38, andproceeds to S40.

In S40, using the communication link of P2P, the CPU 32 performs atwo-way communication with the NFC device via the NFC I/F 22.Specifically, the CPU 32 performs a two-way communication of printrequest data and response data. The CPU 32 first receives the printrequest data from the NFC device via the NFC I/F 22. The print requestdata includes a print instructing command for causing the MFP 10 toexecute the print function. Moreover, the print request data does notinclude print data, this being data of a print target.

As described above, the communication speed of a communication of theNFC scheme is slower than the communication speed of a network wirelesscommunication. Consequently, if the communication of the NFC scheme isused as the communication of print data from the NFC device (i.e., theportable terminals 50, 52) to the MFP 10, the communication of the printdata may require a long time. Consequently, in the present embodiment,the MFP 10 adopts a configuration in which the print data is receivedfrom the NFC device by using a network wireless communication. In orderto adopt such a configuration, the NFC device must know a wirelesssetting for performing a network wireless communication with the MFP 10.Consequently, in case of receiving, from the NFC device, print requestdata that includes a print instructing command, the MFP 10 sends thewireless setting to the NFC device as response data indicating aresponse to the print instructing command.

That is, in S40, the CPU 32 reads the print instructing command includedin the print request data, and identifies, from the memory 34, awireless setting that is being used in the wireless network to which theMFP 10 currently belongs. In S40, the CPU 32 further generates responsedata that includes the identified wireless setting. In S40, using thecommunication link of P2P, the CPU 32 further sends the generatedresponse data to the NFC device via the NFC I/F 22. Thereby, the NFCdevice can join the wireless network by using the wireless settingincluded in the response data. Consequently, the MFP 10 and the NFCdevice perform a network wireless communication instead of acommunication of the NFC scheme, and can communicate the print data.That is, the MFP 10 can receive the print data from the NFC device andexecute the print function. When S40 ends, the CPU 32 proceeds to S42.

In S42, the CPU 32 disconnects the communication link of P2P. Forexample, in case the MFP 10 is the Listen device, the CPU 32 receives aDeactivation command from the NFC device and sends an OK command to theNFC device, as in S24. Consequently, the communication link of P2P isdisconnected. Further, e.g., in case the MFP 10 is the Poll device, theCPU 32 sends a Deactivation command to the NFC device, and receives anOK command from the NFC device. Consequently, the communication link ofP2P is disconnected. Moreover, in case the NFC device moves away fromthe MFP 10 before a communication of the Deactivation command and the OKcommand is performed, in S42 the link may be forcibly disconnectedwithout performing the communication of these commands. When S42 ends,the CPU 32 proceeds to S44.

In S44, the CPU 32 stops the P2P mode, and activates the CE mode.Consequently, the CPU 32 can change the state of the MFP 10 to theinitial state from the state in which the P2P mode is active and the R/Wmode and the CE mode are not active. According to this configuration,the MFP 10 can appropriately return the state of the MFP 10 to theinitial state. When S44 ends, the CPU 32 returns to S20.

(Case A; FIG. 3)

Next, a specific case A realized by the present embodiment will bedescribed with reference to FIG. 3. Case A is realized by the MFP 10executing the processes of FIG. 2.

Case A1 shows a communication performed between the MFP 10 and theportable terminal 50 that comprises the first OS program. In the initialstate of the MFP 10, the CE mode is active, and the P2P mode and the R/Wmode are not active (i.e., P2P=OFF, R/W=OFF, CE=ON). Further, theapplication for MFP has not been installed in the portable terminal 50.Alternatively, the application for MFP has been installed in theportable terminal 50, but the application for MFP has not beenactivated. Consequently, in the initial state of the portable terminal50, the P2P mode and the Reader mode are active, and the Writer mode isnot active (i.e., P2P=ON, Reader=ON, Writer=OFF).

In a state where the application for MFP is not active, a user of theportable terminal 50 brings the portable terminal 50 closer to the MFP10. The CE mode is active in the MFP 10, and the P2P mode and the Readermode are active in the portable terminal 50. In such a situation, only acommunication link of MFP (CE)-NFC device (R) can be established betweenthe MFP 10 and the portable terminal 50 (S20 of FIG. 2). That is, acommunication link of P2P, a communication link of MFP (CE)-NFC device(W), a communication link of the MFP (R)-NFC device (CE), and acommunication link of MFP (W)-NFC device (CE) are not established.

In the case where the communication link of MFP (CE)-NFC device (R) isestablished (the case of YES in S20 of FIG. 2), the MFP 10 sends the URLdata to the portable terminal 50 (S22). Next, the MFP 10 disconnects thecommunication link of MFP (CE)-NFC device (R) (S24).

Upon receiving the URL data from the MFP 10, the portable terminal 50reads the Smart Poster command included in the URL data according to thefirst OS program. In case the application for MFP has not been installedin the portable terminal 50, a first example and a second example beloware realized. In the first example, upon reading the Smart Postercommand, the portable terminal 50 automatically accesses the URLincluded in the URL data (i.e., an internet server storing theapplication for MFP), and downloads the application for MFP from theinternet server. Thereby, the portable terminal 50 can install theapplication for MFP. In the second example, upon reading the SmartPoster command, the portable terminal 50 displays a predetermined screenasking the user whether or not to access the URL included in the URLdata. When the user permits access, the portable terminal 50 downloadsthe application for MFP from the internet server. Thereby, the portableterminal 50 can install the application for MFP. When the applicationfor MFP is installed, the portable terminal 50 activates the applicationfor MFP. Consequently, the portable terminal 50 stops the Reader mode,and activates the Writer mode.

Further, in a case where the portable terminal 50 has installed theapplication for MFP, the portable terminal 50 does not download theapplication for MFP even upon reading the Smart Poster command Uponreading the Smart Poster command, the portable terminal 50, e.g.,activates a predetermined application (browser application, etc.), anddisplays a predetermined screen showing the URL included in the URLdata. When the user executes an operation via the predetermined screento activate the application for MFP, the portable terminal 50 activatesthe application for MFP. Consequently, the portable terminal 50 stopsthe Reader mode, and activates the Writer mode.

The user of the portable terminal 50, in accordance with the screen forthe application for MFP, applies an operation to the portable terminal50 for causing the MFP 10 to perform the print function. The user bringsthe portable terminal 50 closer to the MFP 10. The CE mode is active inthe MFP 10, and the P2P mode and the Writer mode are active in theportable terminal 50. In such a situation, only a communication link ofMFP (CE)-NFC device (W) can be established between the MFP 10 and theportable terminal 50 (S30 of FIG. 2).

The portable terminal 50, in accordance with the application for MFP,sends the P2P activation command to the MFP 10 by using thecommunication link of MFP (CE)-NFC device (W). Consequently, by usingthe communication link of MFP (CE)-NFC device (W), the MFP 10 receivesthe P2P activation command from the portable terminal 50 (YES in S32).Next, the MFP 10 disconnects the communication link of MFP (CE)-NFCdevice (W) (S34).

The MFP 10, in accordance with the P2P activation command, stops the CEmode and activates the P2P mode (S36). The P2P mode is active in the MFP10, and the P2P mode and the Writer mode are active in the portableterminal 50. In such a situation, only the communication link of P2P canbe established between the MFP 10 and the portable terminal 50 (YES inS38 of FIG. 2). Moreover, in case of receiving the P2P activationcommand, the MFP 10 shifts to the state in which only the P2P mode isactive (S36). However, the MFP 10 may shift to a state in which both theP2P mode and the R/W mode are active.

The portable terminal 50 generates print request data in accordance withthe application for MFP. Using the communication link of P2P, theportable terminal 50 sends the print request data to the MFP 10.Consequently, using the communication link of P2P, the MFP 10 receivesthe print request data from the portable terminal 50 (S40). Next, usingthe communication link of P2P, the MFP 10 sends response data thatincludes the wireless setting to the portable terminal 50 (S40).

The portable terminal 50 receives the response data from the MFP 10 byusing the communication link of P2P. Thereby, in accordance with theapplication for MFP, the portable terminal 50 joins the wireless networkby using the wireless setting included in the response data. Theportable terminal 50 performs a network wireless communication, sendingthe print data to the MFP 10.

The MFP 10 performs a network wireless communication, receiving printdata from the portable terminal 50 (not shown in the flowchart andsequence chart). The print data is supplied to the print executing unit18. Thereby, the MFP 10 (i.e., the print executing unit 18) prints animage represented by the print data onto a print medium.

Moreover, when the two-way communication of the print request data andthe response data ends, the MFP 10 disconnects the communication link ofP2P (S42). Next, the MFP 10 stops the P2P mode, and activates the CEmode (S44). Thereby, the MFP 10 returns to the initial state.

Result of Present Embodiment

If the MFP 10 were to adopt a configuration which maintains the state ofthe P2P mode being activated (called “configuration of comparativeexample” below), the following event could occur. In the portableterminal 50, the P2P mode is active even though the application for MFPis not active. Consequently, a communication link of P2P can beestablished between the MFP 10 and the portable terminal 50 even in asituation where the application for MFP is not active in the portableterminal 50. In this case, since the portable terminal 50 is notoperating in accordance with the application for MFP, the portableterminal 50 does not send print request data to the MFP 10. That is,according to the configuration of the comparative example, it ispossible that a two-way communication of the target data (i.e., theprint request data and the response data) is not executed appropriately.

By contrast, in the present embodiment, in the initial state of the MFP10, the CE mode is active and the P2P mode and the R/W mode are notactive. Consequently, unlike the configuration of the comparativeexample, in a situation where the MFP 10 is in the initial state and theapplication for MFP is not active in the portable terminal 50, acommunication link of P2P is not established between the MFP 10 and theportable terminal 50. Consequently, while in the initial state, the MFP10 can appropriately establish the communication link of MFP (CE)-NFCdevice (R) (YES in S20 of FIG. 2). Then, using the communication link ofMFP (CE)-NFC device (R), the MFP 10 sends the URL data to the portableterminal 50 (S22). Thereby, the MFP 10 can cause the portable terminal50 to execute activation of the application for MFP.

Then, the MFP 10 changes the state of the MFP 10 from the initial stateto the state in which the P2P mode is active (S36). Thereby, thecommunication link of P2P is established between the MFP 10 and theportable terminal 50. At this juncture, because the application for MFPis active in the portable terminal 50, the MFP 10 can perform a two-waycommunication of the target data with the portable terminal 50 by usingthe communication link of P2P. According to the present embodiment,unlike the configuration of the comparative example, the two-waycommunication of the target data can be executed appropriately.

Moreover, not only in a situation where the NFC device is the portableterminal 50, but also in a situation where the NFC device is theportable terminal 52, a communication similar to case A of FIG. 3 isperformed, and a similar effect to that described above is obtained.That is, in case the application for MFP is not active in the portableterminal 52, the P2P mode, the Reader mode, and the CE mode are activeand the Writer mode is not active. Consequently, in a situation wherethe MFP 10 is in the initial state and the application for MFP is notactive in the portable terminal 52, a communication link of P2P is notestablished between the MFP 10 and the portable terminal 52.Consequently, while the MFP 10 is in the initial state, the MFP 10 canestablish the communication link of MFP (CE)-NFC device (R) and send theURL data to the portable terminal 52. Subsequent communication issimilar to the communication between the MFP 10 and the portableterminal 50 (case A of FIG. 3).

(Corresponding Relationships)

The MFP 10 and the portable terminals 50, 52 are respectively examplesof “communication device” and “external device”. The initial state ofthe MFP 10 (i.e., the state in which only the CE mode is active, and theP2P mode and the R/W mode are not active) is an example of “firststate”. The CE mode and the Reader mode are respectively examples of“first mode” and “second mode”. The communication link of MFP (CE)-NFCdevice (R), the communication link of P2P, the communication link of MFP(CE)-NFC device (W) are respectively examples of “first type ofcommunication link”, “second type of communication link”, and “thirdtype of communication link”. The URL data and the P2P activation commandare respectively examples of “first data” and “second data”. Further,the timing at which the P2P activation command is received is an exampleof “predetermined timing”.

S20 and S30 of FIG. 2 are examples of “monitoring”. S22, S32, S40 arerespectively examples of “sending”, “receiving” and “performing thetwo-way communication”. S36, S44 are examples of “changing”.

Second Embodiment

In the present embodiment, the initial state of the MFP 10 is differentfrom the first embodiment. That is, in the initial state of the MFP 10,the Reader mode and the CE mode are active, and the P2P mode and theWriter mode are not active. Since the Reader mode is active in the MFP10, the communication link of MFP (R)-NFC device (CE) can beestablished.

Further, the portable terminal 50 is different from the first embodimentin the point of being capable of using not only the P2P mode and the R/Wmode, but also the CE mode. In the initial state of the portableterminal 50 (i.e., the state in which the application for MFP is notactive), the P2P mode and the Reader mode are active, and the Writermode and the CE mode are not active. When the application for MFP isactivated in the portable terminal 50, the portable terminal 50 shiftsfrom the initial state to a state in which the P2P mode, the Writer modeand the CE mode are active, and the Reader mode is not active.

The MFP 10 belongs to a wireless network that includes the AP 4 and thePC 6. Consequently, the MFP 10 can receive print data from the PC 6 viathe AP 4, and perform printing in accordance with the print data.Moreover, the authentication card 54 is a card provided to a user of thePC 6. Even if the print data is received from the PC 6, the MFP 10 doesnot start printing until authentication using the authentication card 54has succeeded. That is, after sending the print data from the PC 6 tothe MFP 10, the user of the PC 6 brings the authentication card 54closer to the MFP 10. The MFP 10 receives, from the authentication card54, an authentication command that includes authentication information(e.g., user ID and password), and executes authentication. When theauthentication succeeds, the MFP 10 starts printing. Thereby, the userof the PC 6 can obtain a printed matter when present near the MFP 10.That is, it is possible to suppress the printed matter being taken awayby a third party.

(Communication Process on MFP; FIG. 4)

Next, contents of a communication process on the MFP 10 of the presentembodiment will be described with reference to FIG. 4. When the power ofthe MFP 10 is turned ON, in S110 the CPU 32 shifts the state of the MFP10 to the initial state in which the Reader mode and the CE mode areactive, and the P2P mode and the Writer mode are not active.

S120 to S124 are similar to S20 to S24 of FIG. 2. However, in S124, incase the state of the MFP 10 is a state in which the Reader mode is notactive (see S170, to be described), the CPU 32 activates the Readermode. Thereby, the CPU 32 can appropriately return the state of the MFP10 from the state in which the Reader mode is not active to the initialstate in which the Reader mode is active.

S130 to S144 are similar to S30 to S44 of FIG. 2. However, in S136 theCPU 32, in accordance with the P2P activation command, stops the Readermode and the CE mode, and activates the P2P mode. Consequently, the CPU32 can change the state of the MFP 10 from the initial state to thestate in which the P2P mode is active, and the R/W mode and the CE modeare not active. Further, in S144 the CPU 32 stops the P2P mode, andactivates the Reader mode and the CE mode. Consequently, the CPU 32 canchange the state of the MFP 10 to the initial state from the state inwhich the P2P mode is active, and the R/W mode and the CE mode are notactive.

As shown in S160, while the state of the MFP 10 is the initial state,the CPU 32 further monitors whether the communication link of MFP(R)-NFC device (CE) is established. In case the MFP 10 executes the Polloperation and the information delivered from the NFC I/F 22 (i.e.,information indicating the activation mode signal received from the NFCdevice that is the Listen device) indicates that the NFC device isactivating the CE mode, the CPU 32 decides that the MFP 10 is to operatein the Reader mode. In this case, the CPU 32 sends an Activation commandcorresponding to the R/W mode to the NFC device, and receives an OKcommand from the NFC device. In case of receiving the OK command fromthe NFC device, the CPU 32 determines that a communication link of MFP(R)-NFC device (CE) has been established. In this case, the CPU 32determines YES in S160, and proceeds to S162.

In S162, S164, by using the communication link of MFP (R)-NFC device(CE), the CPU 32 monitors whether a P2P activation command or anauthentication command is received from the NFC device via the NFC I/F22. In case of receiving the P2P activation command from the NFC device(i.e., the portable terminals 50, 52), the CPU 32 determines YES inS162, and proceeds to S134.

Moreover, in case the NFC device is the authentication card 54, the CPU32 receives the authentication command from the NFC device (i.e., theauthentication card 54). In this case, the CPU 32 determines YES inS164, and proceeds to S166. On the other hand, in the case of notreceiving either the P2P activation command or the authenticationcommand from the NFC device, the CPU 32 determines NO in S164, andproceeds to S168.

In S166, the CPU 32 sends a Deactivation command to the NFC device, andreceives an OK command from the NFC device. Consequently, thecommunication link of MFP (R)-NFC device (CE) is disconnected. Moreover,in case the NFC device moves away from the MFP 10 before thecommunication of the Deactivation command and the OK command isperformed, in S166 the link may be forcibly disconnected withoutexecuting the communication of these commands. Further, although notshown in the flowchart, in the case of receiving the authenticationcommand, the CPU 32 executes authentication of the authenticationinformation included in the authentication command and, in case ofauthentication succeeding, starts printing according to the print data.When S166 ends, the CPU 32 returns to S120. Moreover, in case ofdetermining YES in S164, i.e., in case of receiving the authenticationcommand from the NFC device, the CPU 32 does not stop the Reader mode,as in S170 (to be described). Consequently, the CPU 32 can appropriatelymaintain a state in which the Reader mode is active.

In S168, as in S166, the CPU 32 disconnects the communication link ofMFP (R)-NFC device (CE). Next, in S170, the CPU 32 stops the Readermode. Consequently, the CPU 32 can change the state of the MFP 10 fromthe initial state to the state in which the CE mode is active and theP2P mode and the R/W mode are not active. Thereby, in S172 (to bedescribed), establishment of a communication link for the MFP 10 tooperate in the Reader mode can be suppressed, and a communication linkfor the MFP 10 to operate in the CE mode can be establishedappropriately. When S170 ends, the CPU 32 proceeds to S172.

In S172, as in S120, the CPU 32 monitors whether the communication linkof MFP (CE)-NFC device (R) is established. In case the communicationlink of MFP (CE)-NFC device (R) is established, the CPU 32 determinesYES in S172, and proceeds to S122. Moreover, as described above, in caseof executing S124, which is executed via S170, S172, and S122, in S124the CPU 32 re-activates the Reader mode, which was stopped in S170, andreturns the MFP 10 to the initial state.

(Case B1; FIG. 5)

Next, specific cases B1 to B4 realized by the present embodiment will bedescribed with reference to FIG. 5 to FIG. 8. Cases B1 to B4 arerealized by the MFP 10 executing the processes of FIG. 4.

Case B1 shows a communication performed between the MFP 10 and theportable terminal 50 that comprises the first OS program. In the initialstate of the MFP 10, the Reader mode and the CE mode are active, and theP2P mode and the Writer mode are not active (i.e., P2P=OFF, Reader=ON,Writer=OFF, CE=ON). Further, in the initial state of the portableterminal 50 (i.e., the state in which the application for MFP is notactive), the P2P mode and the Reader mode are active, and the Writermode and the CE mode are not active (i.e., P2P=ON, Reader=ON,Writer=OFF, CE mode=OFF). In such a situation, only the communicationlink of MFP (CE)-NFC device (R) can be established between the MFP 10and the portable terminal 50 (S120 of FIG. 4). Thereafter, processesuntil the portable terminal 50 activates the application for MFP aresimilar to case A of FIG. 3.

When the application for MFP has been activated, the portable terminal50 stops the Reader mode, and activates the Writer mode and the CE mode.In such a situation, the communication link of MFP (CE)-NFC device (W),or the communication link of MFP (R)-NFC device (CE) can be establishedbetween the MFP 10 and the portable terminal 50 (S130 or S160 of FIG.4). In case B1, the communication link of MFP (CE)-NFC device (W) isestablished (YES in S130). Subsequent processes are similar to case A ofFIG. 3, with the exception of the points that, in S136 not only the CEmode, but also the Reader mode is stopped in the MFP 10, and in S144 notonly the CE mode, but also the Reader mode is activated in the MFP 10.

(Case B2; FIG. 6)

On the other hand, in case B2, after the portable terminal 50 hasactivated the application for MFP, the communication link of MFP (R)-NFCdevice (CE) is established (YES in S160 of FIG. 4). In this case, usingthe communication link of MFP (R)-NFC device (CE), the portable terminal50 sends the P2P activation command to the MFP 10 in accordance with theapplication for MFP. Consequently, using the communication link of MFP(R)-NFC device (CE), the MFP 10 receives the P2P activation command fromthe portable terminal 50 (YES in S162). Subsequent processes are similarto case B1 of FIG. 5.

As shown in cases B1 and B2, while in the initial state, the MFP 10 canappropriately establish the communication link of MFP (CE)-NFC device(R) (YES in S120 of FIG. 4), and can send the URL data to the portableterminal 50 (S122). Thereby, the MFP 10 can cause the portable terminal50 to execute the activation of the application for MFP. Then, the MFP10 changes the state of the MFP 10 from the initial state to the statein which the P2P mode is active (S136). Thereby, using the communicationlink of P2P, the MFP 10 can appropriately perform a two-waycommunication of the target data with the portable terminal 50.

Further, after the portable terminal 50 has been caused to execute theactivation of the application for MFP, the communication link of MFP(CE)-NFC device (W), or the communication link of MFP (R)-NFC device(CE) can be established (YES in S130 or YES in S160 of FIG. 4).Regardless of which communication link is established, the MFP 10 canreceive the P2P activation command from the portable terminal 50 (YES inS132 or YES in S162), and can change the state of the MFP 10 from theinitial state to the state in which the P2P mode is active at anappropriate timing (i.e., a timing at which the application for MFP isactive in the portable terminal 50) (S136). Consequently, using thecommunication link of P2P, the MFP 10 can appropriately perform atwo-way communication of the target data with the portable terminal 50.

(Case B3; FIG. 7)

Case B3 shows a communication performed between the MFP 10 and theportable terminal 52 that comprises the second OS program. The initialstate of the MFP 10 is similar to case B1 and B2 of FIG. 5 and FIG. 6.Further, in the initial state of the portable terminal 52 (i.e., thestate in which the application for MFP is not active), the P2P mode, theReader mode, and the CE mode are active, and the Writer mode is notactive (i.e., P2P=ON, Reader=ON, Writer=OFF, CE mode=ON). In such asituation, the communication link of MFP (CE)-NFC device (R), or thecommunication link of MFP (R)-NFC device (CE) can be established betweenthe MFP 10 and the portable terminal 52 (S120 or S160 of FIG. 4). Incase the communication link of MFP (CE)-NFC device (R) is established(in case of YES in S120 of FIG. 4), subsequent processes in the portableterminal 52 are similar to cases B1 and B2 of FIG. 5 and FIG. 6,excepting for the point that the state in which the CE mode is active ismaintained.

On the other hand, in case the communication link of MFP (R)-NFC device(CE) is established (in case of YES in S160 of FIG. 4), since theportable terminal 52 is not operating in accordance with the applicationfor MFP, the portable terminal 52 does not send the P2P activationcommand to the MFP 10. Consequently, the MFP 10 does not receive the P2Pactivation command from the portable terminal 52 (NO in S162). Further,the MFP 10 does not receive the authentication command either (NO inS164). In this case, the MFP 10 disconnects the communication link ofMFP (R)-NFC device (CE) (S168).

Next, the MFP 10 stops the Reader mode (S170). In such a situation, onlythe communication link of MFP (CE)-NFC device (R) can be established(S172). In case the communication link of MFP (CE)-NFC device (R) isestablished (in case of YES in S172), subsequent processes are similarto cases B1 and B2 of FIG. 5 and FIG. 6, excepting for the point that,when the communication link of MFP (CE)-NFC device (R) is disconnected,the Reader mode is activated in the MFP 10, and the point that, in theportable terminal 52, the state in which the CE mode is active ismaintained.

As shown in case B3, the second OS program of the portable terminal 52differs from the first OS program of the portable terminal 50, andactivates the CE mode even though the application for MFP is not active.Consequently, even though the application for MFP is not active in theportable terminal 52, the communication link of MFP (R)-NFC device (CE)between the MFP 10 and the portable terminal 52 can be established (YESin S160). In this case, since the MFP 10 does not receive a P2Pactivation command from the portable terminal 52 (NO in S162, S164), theMFP 10 stops the Reader mode (S170). Since the Reader mode is stopped inS170, the communication link of MFP (CE)-NFC device (R) is establishedappropriately between the MFP 10 and the portable terminal 52 (YES inS172). Consequently, the MFP 10 can appropriately cause the portableterminal 52 to execute activation of the application for MFP (S122).

(Case B4; FIG. 8)

Case B4 shows a communication executed between the MFP 10 and theauthentication card 54. The initial state of the MFP 10 is similar tocases B1 to B3 of FIG. 5 to FIG. 7. Further, only the CE mode is activein the authentication card 54. In such a situation, only thecommunication link of MFP (R)-NFC device (CE) can be established betweenthe MFP 10 and the authentication card 54 (S160 of FIG. 4). In case thecommunication link of MFP (R)-NFC device (CE) is established (in case ofYES in S160), the MFP 10 receives an authentication command from theauthentication card 54 (YES in S164). Next, the MFP 10 disconnects thecommunication link of MFP (R)-NFC device (CE) (S166).

Moreover, the MFP 10 has received the print data from the PC 6 via theAP 4 before receiving the authentication command Upon receiving theauthentication command, the MFP 10 executes an authentication by usingauthentication information included in the authentication command. Whenthe authentication succeeds, the MFP 10 starts printing according to thereceived print data.

As shown in case B4, in the initial state of the MFP 10, not only the CEmode, but also the Reader mode is active, and consequently thecommunication link of MFP (R)-NFC device (CE) is established between theMFP 10 and the authentication card 54 (S160). In this case, the MFP 10receives an authentication command from the authentication card 54 (YESin S164), and can execute an authentication. According to the presentembodiment, while realizing a configuration that executes anauthentication using the authentication card 54, the MFP 10 canappropriately perform a two-way communication of target data with theportable terminals 50, 52, as in cases B1 to B3.

(Corresponding Relationships)

Corresponding relationships of the second embodiment are basicallysimilar to the corresponding relationships of the first embodiment.Points of difference are given below. The portable terminals 50, 52 andthe authentication card 54 are an example of “external device”. Theinitial state of the MFP 10 (i.e., the state in which the CE mode andthe Reader mode are active, and the P2P mode and the Writer mode are notactive) is an example of “first state”. The state in which only the CEmode is active (i.e., the state after S170 of FIG. 4 has been executed)is an example of “third state”. The authentication command is an exampleof “third data”. S120, S130, and S160 of FIG. 4 are examples of“monitoring”. S122 is an example of “sending”. S132, S162, and S164 areexamples of “receiving”. S140 is an example of “performing the two-waycommunication”. S136, S144, S170, S124 are examples of “changing”.

(Variant 1)

In the initial state of the MFP 10, the Writer mode is active, and theP2P mode, the Reader mode, and the CE mode need not be activated.Further, the initial state of the portable terminal 52 may be similar tothe state shown in case B3 of FIG. 7. In this case, only a communicationlink of MFP (W)-NFC device (CE) can be established between the MFP 10and the portable terminal 52. In case the communication link of MFP(W)-NFC device (CE) is established, the CPU 32 of the MFP 10 may sendthe URL data to the portable terminal 52 by using the communication linkof MFP (W)-NFC device (CE). Thereby, the MFP 10 can cause the portableterminal 52 to execute an activation of the application for MFP. Then,the CPU 32 may change the state of the MFP 10 from the initial state tothe state in which the P2P mode is active. In the present variant, also,the MFP 10 can appropriately cause the portable terminal 52 to executean activation of the application for MFP, and consequently canappropriately execute a two-way communication of the target data withthe portable terminal 52. In the present variant, the state in whichonly the Writer mode is active is an example of the “first state”. TheWriter mode and the CE mode are respectively examples of the “firstmode” and the “second mode”. The “first state” may be e.g., a state inwhich the P2P mode is not active, and a first mode different from theP2P mode is active. Further, the communication link of MFP (W)-NFCdevice (CE) is an example of the “first type of communication link”. The“first type of communication link” may be e.g., a communication linkcapable of performing a one-way communication of first data from thecommunication device to an external device.

(Variant 2)

In the above embodiments, the URL data which includes the Smart Postercommand is an example of the “first data”. Instead, e.g., in case thefirst OS program of the portable terminal 50 is Android (registeredtrademark) (e.g., in case of a program having version 4.0 or later) the“first data” may be data that includes an Android (registered trademark)application record. That is, in S22 of FIG. 2 or S122 of FIG. 4, the CPU32 may send the application record instead of the URL data. Theapplication record may not include the URL of the application for MFP,but include a package name (i.e., text information) of the applicationfor MFP. The portable terminal 50 can install and activate theapplication for MFP by using the package name included in theapplication record. In the present variant, the data that includes theapplication record is an example of the “first data”.

(Variant 3)

In the portable terminals 50, 52, assuming that the application for MFPhas been installed, data that includes an activation command of theapplication for MFP (not including an URL) may be adopted, instead ofthe URL data, as the “first data”. That is, in general terms, the “firstdata” may be any data that includes a command for causing an externaldevice to activate a particular application for performing a two-waycommunication of target data.

(Variant 4)

In the above embodiments, the timing at which the P2P activation commandis received is an example of the “predetermined timing”. Instead, theCPU 32 may activate the P2P mode at a timing when a predetermined timehas elapsed since the URL data was sent to the portable terminals 50, 52(e.g., a timing when an estimated time has elapsed that is required forthe application for MFP to be activated in the portable terminals 50,52). According to this configuration, the timing when the predeterminedtime has elapsed is an example of the “predetermined timing”. The“changing” may be any step in which the state of the communicationdevice changes from the first state to the second state at apredetermined timing after sending the first data. Moreover, in thepresent variant, S36 to S44 may be executed in FIG. 2 after S24 has beenexecuted, without executing S30 to S34. In general terms, the processormay be any processor that performs at least the monitoring step (e.g.,S20), the sending step (e.g., S22), the first changing step (e.g., S36),and the communication step (e.g., S40).

(Variant 5)

In the above embodiments, the state in which the P2P mode is active andthe CE mode and the R/W mode are not active (i.e., the state after S36or S136 of FIG. 2 or FIG. 4 has been executed) is an example of the“second state”. Instead, the “second state” may be a state in which notonly the P2P mode, but also at least one mode of the CE mode, the Readermode, and the Writer mode is active. That is, the “second state” may beany state in which at least the P2P mode is active.

(Variant 6)

In the second embodiment, the authentication command is an example ofthe “third data”. Instead, the “third data” may be another type of data(e.g., data regarding electronic money, etc.) to be communicated by theNFC scheme.

(Variant 7)

In the above embodiments, the print request data and the response dataare an example of the “target data” of the target of the two-waycommunication. Instead, e.g., the variants below may be adopted.

(Variant 7-1)

Scan request data that includes a scan instructing command for causingthe MFP 10 to execute the scan function, and response data whichincludes a wireless setting may be adopted as the “target data”.

(Variant 7-2)

For example, a situation is assumed in which the portable terminal 50should send, to the MFP 10, setting information to be used by the MFP10. The following can be given as the setting information: e.g., printsetting information (e.g., print resolution, paper size, etc.) for theMFP 10 to perform the print function, scan setting information (e.g.,scan resolution, etc.) for the MFP 10 to perform the scan function, andcommunication setting information (e.g., IP address, subnet mask,gateway address, etc.) for the MFP 10 to perform a communicationfunction. Thereby, the MFP 10 can perform the various functions by usingthe setting information received from the portable terminal 50. In caseof receiving the setting information from the portable terminal 50, theMFP 10 sends a response command to the portable terminal 50, indicatingthat the setting information was received. The setting information andthe response command may be adopted as the “target data”.

(Variant 7-3)

For example, a situation is assumed in which the portable terminal 50should send, to the MFP 10, address information that is included in anaddress book in the portable terminal 50. The MFP 10 can perform thecommunication function by using the address information received fromthe portable terminal 50. In case of receiving the address informationfrom the portable terminal 50, the MFP 10 sends a response command tothe portable terminal indicating that the address information wasreceived. The address information and the response command may beadopted as the “target data”.

(Variant 7-4)

In the above embodiments, a configuration is adopted in which the MFP 10receives print data from the portable terminal 50 by using a networkwireless communication. Instead, e.g., the MFP 10 may receive print datafrom the portable terminal 50 by using an NFC communication. In thiscase, the MFP 10 may send a response command to the portable terminal 50indicating that the print data was received. The print data and theresponse command may be adopted as the “target data”.

(Variant 7-5)

Further, in the above embodiments and the variants 7-1 to 7-4, thesending of target data from the portable terminal 50 to the MFP 10 isrealized, and then the sending of the target data from the MFP 10 to theportable terminal 50 is realized. Instead, the sending of target datafrom the MFP 10 to the portable terminal 50 may be realized, and thenthe sending of the target data from the portable terminal 50 to the MFP10 may be realized. That is, the “performing the two way-communication”may be any step that performs a two-way communication of the targetdata.

(Variant 8)

The “communication device” is not restricted to a multi-functionperipheral capable of executing the print function and the scan function(i.e., the MFP 10), but may be a printer that is capable of executingonly the print function from among the print function and the scanfunction, or may be a scanner that is capable of executing only the scanfunction from among the print function and the scan function. Further,the “communication device” may be a device that executes a functiondifferent from the print function and the scan function (e.g., an imagedisplay function, a data calculation function) (e.g., PC, server,portable terminal (portable telephone, smart phone, PDA, etc.)). Thatis, the “communication device” includes any device capable of performinga communication of the NFC scheme. Further, the “external device” is notrestricted to the portable terminals 50, 52 and the authentication card54, but includes any device capable of performing a communication of theNFC scheme.

(Variant 9)

In the above embodiments, the processes of FIG. 2 or FIG. 4 are realizedby software (i.e., the program 36), but at least one of the processes ofFIG. 2 or FIG. 4 may be realized by hardware such as a logic circuit,etc.

What is claimed is:
 1. A communication device configured to perform aPeer-to-Peer (P2P) communication with an external device according to anNear Field Communication (NFC) scheme complying with an NFC standard,the communication device comprising: an NFC interface configured tooperate in the NFC scheme; a processor; and a memory configured to storecomputer executable instructions, wherein the computer executableinstructions, when executed by the processor, cause the communicationdevice to execute: monitoring an establishment of a first type ofcommunication link between the communication device and the externaldevice while the communication device is in a first state in which a P2Pmode of the NFC standard is not active and a first mode of the NFCstandard is active, the first type of communication link being forperforming a data communication between the communication device in thefirst mode and the external device in a second mode of the NFC standard;changing a state of the communication device from the first state to asecond state in which the P2P mode is active in a case where the firsttype of communication link is established while the communication deviceis in the first state; and performing the P2P communication of targetdata with the external device via the NFC interface by using a secondtype of communication link, in a case where the second type ofcommunication link is established between the communication device andthe external device while the communication device is in the secondstate, the second type of communication link being for performing a datacommunication between the communication device in the P2P mode and theexternal device in the P2P mode, and the P2P communication includingsending the target data to the external device without receiving arequest of sending the target data from the external device.
 2. Thecommunication device as in claim 1, wherein the computer executableinstructions, when executed by the processor, cause the communicationdevice to further execute: sending first data to the external device viathe NFC interface by using the first type of communication link, in thecase where the first type of communication link is established while thecommunication device is in the first state, the first data including acommand for causing the external device to execute an activation of aparticular application, the particular application configured to performthe P2P communication, wherein the changing is executed at apredetermined timing after sending the first data, and the P2Pcommunication of the target data is performed with the external devicethat operates the particular application.
 3. The communication device asin claim 1, wherein the P2P communication includes receiving anothertarget data after sending the target data to the external device.
 4. Thecommunication device as in claim 1, further comprising: a networkinterface configured to perform a communication of a Wi-Fi scheme,wherein the target data being sent to the external device includes awireless setting used in a wireless network of the Wi-Fi scheme to whichthe communication device belongs, wherein the computer executableinstructions, when executed by the processor, cause the communicationdevice to further execute: performing a communication of specific datawith the external device via the network interface by using the wirelessnetwork of the Wi-Fi scheme.
 5. The communication device as in claim 1,wherein the first mode is a Reader mode or a Writer mode of the NFCscheme.
 6. The communication device as in claim 1, wherein the computerexecutable instructions, when executed by the processor, cause thecommunication device to further execute: changing a state of thecommunication device from the second state to the first state afterperforming the P2P communication of the target data with the externaldevice.
 7. A non-transitory computer readable medium storing computerexecutable instructions that, when executed by a processor of acommunication device having a Near Field Communication (NFC) interfaceconfigured to operate under an NFC scheme, cause the communicationdevice to: monitor an establishment of a first type of communicationlink between the communication device and an external device while thecommunication device is in a first state in which a Peer-to-Peer (P2P)mode of an NFC standard is not active and a first mode of the NFCstandard is active, the first type of communication link being forperforming a data communication between the communication device in thefirst mode and the external device in a second mode of the NFC standard;change a state of the communication device from the first state to asecond state in which the P2P mode is active in a case where the firsttype of communication link is established while the communication deviceis in the first state; and perform P2P communication of target data withthe external device via the NFC interface of the communication device byusing a second type of communication link, in a case where the secondtype of communication link is established between the communicationdevice and the external device while the communication device is in thesecond state, the second type of communication link being for performinga data communication between the communication device in the P2P modeand the external device in the P2P mode, and the P2P communicationincluding sending the target data to the external device withoutreceiving a request of sending the target data from the external device.